<?php
namespace app\api\controller\v1;
class Base extends \app\api\controller\Base
{
    public static function  request_post($url = '', $param = '',$header = 'Content-Type: application/json') {
        if (empty($url) || empty($param)) {
            return '数据不全';
        }
        $headers = array($header);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

        curl_setopt($ch, CURLOPT_POST, TRUE);   //is it optional?
        curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
        $data = curl_exec($ch);
//        var_dump(curl_error($ch));
        curl_close($ch);
        return $data;
    }
}